{include "Public/header"}
<div class="container-fluid">
  <div class="row-fluid">
    <div class="span12">
      <div class="widget-box">
        <div class="widget-title"> <span class="icon"> <i class="icon-align-justify"></i> </span>
          <h5>{$title}</h5>
        </div>
        <div class="widget-content nopadding">
          <form action="" method="post" class="form-horizontal">
          {if isset($info)}
          <input type="hidden" name="id" value="{$info['id']}" />
          {/if}
            <div class="control-group">
              <label class="control-label">username</label>
              <div class="controls">
                <input type="text" maxlength="20" name="username" class="span11" value="{$info['username']|''}" {if isset($info)}disabled{/if} placeholder="please input the username" />
              </div>
            </div>
            <div class="control-group">
              <label class="control-label">password</label>
              <div class="controls">
                <input type="password" maxlength="32" name="password" class="span11" value="" placeholder="password" />
                {if isset($info)}
                <span class="help-block blue span8">Do not change the password, please keep the air</span>
                {/if}
              </div>
            </div>
            <div class="control-group">
              <label class="control-label">power</label>
              <div class="controls">
                <select name="role_id">
                	{foreach $roleList as $v}
                	<option value="{$v['id']}" {if isset($info)&&$info['role_id']==$v['id']}selected{/if}>{$v['name']}</option>
                	{/foreach}
                </select>
              </div>
            </div>
            <div class="control-group">
              <label class="control-label">Name</label>
              <div class="controls">
                <input type="text" maxlength="50" name="name" class="span11" value="{$info['name']|''}" placeholder="Name" />
              </div>
            </div>
            <div class="form-actions">
              <input type="submit" class="btn btn-success" value="save">
            </div>
          </form>
        </div>
      </div>
     </div>
</div></div>
{include "Public/footer"}
<script>
$(function(){
	$("form").validate({
		rules:{
			username:{
				required:true,
				rangelength:[4,20],
				remote:{
					url:"{:U('Public/isUsernameExists')}",
					type:"get"
				}
			}
			{if !isset($info)}
			,
			password:{
				required:true,
				rangelength:[6,32]
			}
			{/if}
		},
		messages:{
			username:{
				required:"required",
				rangelength:"User name in 4-20",
				remote:"username existed"
			},
			password:{
				required:"required",
				rangelength:"password in 6-32"
			}
		}
	});
	
});
</script>